package com.grad.why.studentsystem.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.grad.why.studentsystem.domain.Authorityinfos;
import com.grad.why.studentsystem.domain.Menu;
import com.grad.why.studentsystem.domain.current.CurrentAuthorityInfo;
import com.grad.why.studentsystem.mapper.AuthorityinfosMapper;
import com.grad.why.studentsystem.service.AdminService;
import com.grad.why.studentsystem.service.AuthorityService;
import com.grad.why.studentsystem.service.MenuService;
import org.apache.tools.ant.taskdefs.EchoXML;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Component
@Transactional
@Service(interfaceClass = AuthorityService.class)
public class AuthorityServiceImpl implements AuthorityService{
    @Autowired
    private AuthorityinfosMapper authorityinfosMapper;

    @Override
    public List<CurrentAuthorityInfo> getAuthorityInfos(int offset, int limit, String search) {
        try{
            return  authorityinfosMapper.getAuthorityInfos(offset,limit,search);
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }

    @Override
    public long getAuthorityInfosLength(String search) {
        try{
            return authorityinfosMapper.getAuthorityInfosLength(search);
        }catch (Exception e){
            e.printStackTrace();
        }
        return 0;
    }

    @Override
    public int delAuthorityInfoById(long l) {
        try{
            return authorityinfosMapper.deleteByPrimaryKey(l);
        }catch (Exception e){
            e.printStackTrace();
        }
        return 0;
    }

    @Override
    public Authorityinfos getAuthorityInfoById(long l) {
        try{
            return authorityinfosMapper.selectByPrimaryKey(l);
        }catch (Exception E){
            E.printStackTrace();
        }
        return null;
    }

    @Override
    public int checkAuthorityExist(Authorityinfos authorityinfos) {
        try{
            return authorityinfosMapper.checkAuthorityExist(authorityinfos);
        }catch (Exception E){
            E.printStackTrace();
        }
        return 0;
    }

    @Override
    public long getMaxId() {
        try{
            return authorityinfosMapper.getMaxId();
        }catch (Exception e){
            e.printStackTrace();
        }
        return 0;
    }

    @Override
    public int insertAuthorityInfoByEtity(Authorityinfos authorityinfos) {
        try{
            return authorityinfosMapper.insertSelective(authorityinfos);
        }catch (Exception E){
            E.printStackTrace();
        }
        return 0;
    }

    @Override
    public int updateAuthorityByEntity(Authorityinfos authorityinfos) {
        try{
            return authorityinfosMapper.updateByPrimaryKeySelective(authorityinfos);
        }catch (Exception E){
            E.printStackTrace();
        }
        return 0;
    }


}
